<template>
  <div>
    <el-tree
      :data="treeData"
      :props="defaultProps"
      :default-expand-all="true"
    ></el-tree>
  </div>
</template>

<script>
import { getDepartments } from '@/api/departments'
import { formatTreeData } from '@/utils/index'
export default {
  name: 'GetTreeData',
  data () {
    return {
      companyId: '',
      companyManage: '',
      companyName: '',
      // 公司组织架构数据
      treeData: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    }
  },
  // mounted () {
  //   this.getTreeData()
  // },
  methods: {
    async getTreeData () {
      const res = await getDepartments()
      console.log(res)
      this.treeData = formatTreeData(res.depts)
      this.companyId = res.companyId
      this.companyManage = res.companyManage
      this.companyName = res.companyName
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
